// import { dateUtil } from '/@/utils/dateUtil';
import { BasicColumn, FormSchema } from '/@/components/Table';
// import { useI18n } from '/@/hooks/web/useI18n';
// import { FormSchemaExt } from '/@/api/lamp/common/formValidateService';
// import { query as queryApplication } from '/@/api/devOperation/application/defApplication';
import { query as queryTenant } from '/@/api/devOperation/tenant/tenant';
import { TenantStatusEnum } from '/@/enums/biz/tenant';
import { useUserStore } from '/@/store/modules/user';
const userStore = useUserStore();
const otherIds = userStore.getTenantId;
export const searchFormSchema: FormSchema[] = [
  // {
  //   field: 'otherId',
  //   component: 'Select',
  //   label: '请选择二级院部',
  //   colProps: { span: 8 },
  //   componentProps: {
  //     options: [
  //       { value: '520154675945986049', label: '计算机与信息技术学院', key: '1' },
  //       { value: '520154675945986052', label: '商学院', key: '2' },
  //       { value: '520154675945986055', label: '教务处', key: '3' },
  //       { value: '526891104516526724', label: '智能制造技术学院', key: '4' },
  //       { value: '526891104516526727', label: '仲景中医药与健康学院', key: '5' },
  //       { value: '526891104516526732', label: '教育学院', key: '6' },
  //       { value: '526891104516526749', label: '建筑与艺术设计学院', key: '7' },
  //       { value: '526891104516526752', label: '体育学院', key: '8' },
  //       { value: '526891104516526755', label: '中专部', key: '9' },
  //       { value: '526891104516526758', label: '公共教学部', key: '10' },
  //       { value: '526891104516526761', label: '马克思主义学院', key: '11' },
  //       { value: '526891104516526764', label: '继续教育学院', key: '12' },
  //       { value: '526891104516526767', label: '党群工作部', key: '13' },
  //       { value: '526891104516526770', label: '党政办公室', key: '14' },
  //       { value: '526891104516526774', label: '发展规划处（创新创业学院）', key: '15' },
  //       { value: '526891104516526777', label: '人力资源部', key: '16' },
  //       { value: '526891104516526780', label: '科技外事处', key: '17' },
  //       { value: '526891104516526783', label: '学生工作处', key: '18' },
  //       { value: '526891104516526786', label: '法务监督部', key: '19' },
  //       { value: '526891104516526789', label: '招生工作办公室', key: '20' },
  //       {
  //         value: '526891104516526796',
  //         label: '大学生实习实训与就业指导中心（校地合作处）',
  //         key: '21',
  //       },
  //       { value: '526891104516526799', label: '财务处', key: '22' },
  //       { value: '526891104516526802', label: '基建处', key: '23' },
  //       { value: '526891104516526805', label: '保卫处', key: '24' },
  //       { value: '526891104516526808', label: '后勤管理处', key: '25' },
  //       { value: '526891104516526813', label: '心理健康教育中心', key: '26' },
  //       { value: '526891104516526823', label: '图书馆', key: '27' },
  //       { value: '526891104516526831', label: '后勤服务集团直属党支部', key: '28' },
  //     ],
  //   },
  // },
  {
    field: 'otherId',
    label: '请选择二级院部',
    component: 'ApiSelect',
    componentProps: ({ tableAction }) => {
      return {
        api: queryTenant,
        labelField: 'name',
        valueField: 'id',
        params: {
          status: TenantStatusEnum.NORMAL,
        },
        showSearch: true,
        filterOption: (input: string, option: any) => {
          return option.label.toUpperCase().indexOf(input.toUpperCase()) >= 0;
        },
        onChange: (value) => {
          const { reload } = tableAction;
          reload({ searchInfo: { otherId: value } });
        },
      };
    },
    ifShow: otherIds == '1',
    colProps: { span: 8 },
  },
  {
    label: '请选择年份',
    field: 'targetYear',
    component: 'Select',
    colProps: { span: 8 },
    componentProps: {
      options: Array.from({ length: 21 }, (_, index) => ({
        label: 2023 + index + '',
        value: 2023 + index,
      })),
    },
  },
];

export const columns: BasicColumn[] = [
  {
    title: '目标类型',
    dataIndex: 'targetType',
    // customCell: (record) => ({
    //   rowSpan: record.mergeRows,
    // }),
    customRender: ({ record }) => {
      const txts: String = record.echoMap.targetType;
      // return <span style={{ textAlign: 'center' }}>{txts}</span>;
      if (record.echoMap.targetType != undefined) {
        if (record.index == undefined) {
          return <span style={{ textAlign: 'center' }}>{txts}</span>;
        } else {
          const indexNum = record.index;
          const displayText = ` ${indexNum}`;
          return <p>{displayText}</p>;
        }
      } else {
        return;
      }
    },
    width: 80,
  },
  {
    title: '目标项目',
    dataIndex: 'targetDetail',
    width: 130,
    customRender: ({ record }) => {
      if (record.targetDetail == undefined) {
        return <span style={{ textAlign: 'center' }}>--</span>;
      } else {
        const txts: String = record.targetDetail;
        return <span style={{ textAlign: 'center' }}>{txts}</span>;
      }
    },
    // customCell: (record, index: number) => ({
    //   // rowSpan: record.mergeRows,
    //   rowSpan: 3,
    //   // colSpan: index > 33 ? 0 : 1,
    //   colspan: index % 3 ? 0 : 1,
    // }),
    // customCell: (record, index, column) => {
    //   const rowIndex = index; // 当前数据在表格中所在的行索引
    //   const columnIndex = column.key; // 当前数据在表格中所在的列索引

    //   console.log('当前数据:', record);
    //   console.log('当前行索引:', rowIndex);
    //   console.log('当前列索引:', columnIndex);

    //   // 在这里可以根据需要处理当前数据、行索引和列索引
    // },
  },
  {
    title: '目标分值',
    dataIndex: 'targetScore',
    width: 60,
    customRender: ({ record }) => {
      if (record.targetScore == undefined) {
        return <span style={{ textAlign: 'center' }}>--</span>;
      } else {
        const txts: String = record.targetScore;
        return <span style={{ textAlign: 'center' }}>{txts}</span>;
      }
    },
  },
  {
    title: '一级指标',
    dataIndex: 'oneLevelDetail',
    width: 145,
    customRender: ({ record }) => {
      if (record.oneLevelDetail == undefined) {
        return <span style={{ textAlign: 'center' }}>--</span>;
      } else {
        const txts: String = record.oneLevelDetail;
        return <span style={{ textAlign: 'center' }}>{txts}</span>;
      }
    },
  },
  {
    title: '一级分值',
    dataIndex: 'oneLevelScore',
    width: 55,
    customRender: ({ record }) => {
      if (record.oneLevelScore == undefined) {
        return <span style={{ textAlign: 'center' }}>--</span>;
      } else {
        const txts: String = record.oneLevelScore;
        return <span style={{ textAlign: 'center' }}>{txts}</span>;
      }
    },
  },

  {
    title: '二级指标',
    dataIndex: 'twoLevelDetail',
    width: 145,
    customRender: ({ record }) => {
      if (record.twoLevelDetail == undefined) {
        return <span style={{ textAlign: 'center' }}>--</span>;
      } else {
        const txts: String = record.twoLevelDetail;
        return <span style={{ textAlign: 'center' }}>{txts}</span>;
      }
    },
  },
  {
    title: '二级分值',
    dataIndex: 'twoLevelScore',
    width: 55,
    customRender: ({ record }) => {
      if (record.twoLevelScore == undefined) {
        return <span style={{ textAlign: 'center' }}>--</span>;
      } else {
        const txts: String = record.twoLevelScore;
        return <span style={{ textAlign: 'center' }}>{txts}</span>;
      }
    },
  },
  // {
  //   title: '工作类型',
  //   dataIndex: 'workType',
  //   width: 100,
  // },
  // {
  //   title: '评分标准',
  //   dataIndex: 'markingCriterion',
  //   width: 100,
  // },
  {
    title: '截止时间',
    dataIndex: 'deadline',
    width: 65,
    customRender: ({ record }) => {
      if (record.deadline == undefined) {
        return <span style={{ textAlign: 'center' }}>--</span>;
      } else {
        const txts: String = record.deadline;
        return <span style={{ textAlign: 'center' }}>{txts}</span>;
      }
    },
  },
];
